package com.my.serviceimpl;

import com.my.bean.Purchasing;
import com.my.bean.ResultPage;
import com.my.bean.VoPage;
import com.my.mapper.PurchasingMapper;
import com.my.service.PurchasingService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 每日采购材料 服务实现类
 * </p>
 *
 * @author 闫亚茹
 * @since 2018-08-29
 */
@Service
public class PurchasingServiceImpl extends ServiceImpl<PurchasingMapper, Purchasing> implements PurchasingService {
	@Autowired
    PurchasingMapper purchasingMapper;

	/**
	 * 查询
	 * @param purchasing
	 * @return
	 */
	public List<Purchasing> select(Purchasing purchasing){
	    return purchasingMapper.select(purchasing);
    }


	/**
	 * 实现分页查询
	 * @param voPage
	 * @return
	 */
	@Override
	public ResultPage<Purchasing> selectMyPage(VoPage voPage,String type) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("page", (voPage.getPage() - 1)*voPage.getLimit());
		paramMap.put("limit", voPage.getLimit());
		paramMap.put("type", type);
		List<Purchasing> list = baseMapper.selectMyPage(paramMap);
		Integer count = baseMapper.countMyPage(paramMap);
		ResultPage<Purchasing> resultPage=new ResultPage<>();
		resultPage.setCode(0);
		resultPage.setCount(count);
		resultPage.setMsg("成功");
		resultPage.setData(list);
		return resultPage;
	}



}
